<%inherit file="../../dashboard/base.html" />
<%def name="content()">
<%! from django.shortcuts import reverse %>
    % if sub:
        <div style="margin-left: 33%;margin-top: 5%">
        <table style="border: 1px solid #cccccc">
            <thead style="line-height: 40px">
            <td style="border: 1px solid #cccccc">movieId</td>
            <td style="border: 1px solid #cccccc;text-align: center">title</td>
            <td style="border: 1px solid #cccccc;text-align: center">genres</td>
            <td style="border: 1px solid #cccccc;text-align: center">编辑</td>
            </thead>
            % for i in sub:
            <tbody style="line-height: 40px">
            <tr>
                <td style="border: 1px solid #cccccc;text-align: center">${i.movieId}</td>
                <td style="border: 1px solid #cccccc">${i.title}</td>
                <td style="border: 1px solid #cccccc">${i.genres}</td>
                <td style="border: 1px solid #cccccc"><a class="cancel" id="${i.movieId}">取消收藏</a></td>
            </tr>
            </tbody>
        % endfor
        </table>
        </div>
    % else:
        <h2 style="margin: 0 auto;width: 300px;margin-top: 30px">${msg}</h2>
    % endif
</%def>

<%def name="js()">
<script>
    $(".cancel").click(function () {
        var url = '${reverse('cancelupdate')}';
        var movieid = $(this).attr('id');

             $.ajax({
                 url: url,
                 type: 'get',
                 data: {
                     movieid: movieid
                 },
                 success: function (data) {
                     alert(data.msg);
                     window.location.reload()
                 }
             })
         })
</script>
</%def>